//
// Created by Jeffrey Wei on 2022/11/2.
// Copyright (c) 2022 CocoaPods. All rights reserved.
//

import Foundation
import Moya
import SwiftAppKit

protocol BaseTargetType: NetworkTargetType {}

extension BaseTargetType {
//    public var accessToken: (type: AuthorizationType, value: String)? {
//        (type: .bearer, value: "这里存token值")
//    }
    public var responseType: NetworkResponse.Type {
        BaseApiResponse.self
    }

    public var baseURL: URL {
        URL(string: "https://gitee.com/jeff-yunquan/yqappkit/blob/master/YQAppKit/Cla")!
    }

    public var headers: [String: String]? {
        nil
    }
}

extension BaseTargetType {
    public func handleError(error: NetworkError) {
        switch error {
        case .parsingJsonError:
            break
        case let .apiError(response: response):
            print("请求失败,业务结果是==>", response)
        case .notReachableNetwork:
            break
        case let .serviceError(response: response):
            print("请求失败,http状态码是=>>", response?.statusCode)
        }
    }
}
